const App = {
    mixins: [Query],//配置文件，路径/utils/mixins.js
    data() {
        return {
            page: {
                value1: '',
                value2:'',
                PageNumber: 1, //页码
                RowAmount: 10,
                Condition: window.btoa(unescape(encodeURIComponent("%%,%%,%%,%%")))
            },
        }
    },
    mounted() {

    },
    methods: {
        check() {
            this.page.Condition = window.btoa(unescape(encodeURIComponent("%%,%%,%" + this.page.value1 + "%,%"+this.page.value2+"%")));
            this.postgetList(this.page)
        },
        Treedata() {
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalQueryByTableName`,
                type: "POST",
                data: {
                    Data: "merchant",
                    Condition: "Row_Status='0'",
                },
                success: (data) => {
                    $.ajax({
                        headers: requestHeaders(),
                        url: `${mh}/generalBusiness/generalQueryBySQLSerialNumber`,
                        method: "post",
                        data: {
                            SQLSerialNumber: 'f_merchant_business_mapping_blue_plate',
                            Condition: '',
                            ExtensionCondition: '',
                        },
                        success: (data1) => {
                            let treeData = [];
                            data.forEach(item => {
                                let arr = data1.filter(i => i.Merchant_SerialNumber == item.Merchant_SerialNumber)
                                if (arr.length > 0) {
                                    let children = [];
                                    arr.forEach(obj => {
                                        children.push({
                                            id: obj.Merchant_Mapping_Blue_Plate_SerialNumber,
                                            Merchant_Category_SerialNumber: obj.Merchant_Category_SerialNumber,
                                            Blue_Plate_SerialNumber: obj.Blue_Plate_SerialNumber,
                                            name: obj.Merchant_Alias,
                                        })
                                    });
                                    treeData.push({
                                        id: item.Merchant_SerialNumber,
                                        name: item.Merchant_Name,
                                        children,
                                    })
                                }
                            });
                            this.treeData = treeData;
                        },
                        complete: (XMLHttpRequest) => {
                            requestPretreatment(XMLHttpRequest);
                        },
                        dataType: "json",
                    });
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json",
            });
        },
        handle1(data, is) {
            this.$confirm('该操作将' + (is == '2' ? '确认预约' : is == '3' ? '取消预约' : '') + ',是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            }).then(() => {
                let { TableName, primary_key } = JSON.parse(document.getElementById("table").getAttribute("data-options"));
                $.ajax({
                    headers: requestHeaders(),
                    url: `${mh}/generalBusiness/generalQueryByTableNameWithOriginal`,
                    method: "post",
                    data: {
                        Data: TableName,
                        Condition: primary_key + "='" + data[primary_key] + "'"
                    },
                    success: (res) => {
                        if (res.length == 1) {
                            res[0].Row_Status = is;
                            let lJSONObject_DataSet = new Object();
                            let lJSONObject_Table = new Object();
                            lJSONObject_Table[TableName] = res;
                            lJSONObject_DataSet['Modify'] = lJSONObject_Table;
                            let Operation_Main = JSON.stringify(deepClone(lJSONObject_DataSet));
                            if (!lJSONObject_DataSet['Add']) {
                                lJSONObject_DataSet['Add'] = new Object();
                            }
                            lJSONObject_DataSet['Add']['base_operation_log'] = [{
                                Operation_Type: '0',
                                Operation_Path: this.relativePath,
                                Operation_Main,
                                Operation_Interface: "generalSave",
                                Operation_IP: getIpAddress()
                            }]
                            submitSave(lJSONObject_DataSet, (res) => {
                                if (res.Status == 'success') {
                                    this.$message({
                                        type: 'success',
                                        message: '操作成功'
                                    });
                                    this.postgetList(this.page);
                                } else {
                                    this.$message({
                                        type: 'error',
                                        message: '操作失败'
                                    });
                                }
                            })
                        } else {
                            this.$message({
                                type: 'error',
                                message: '操作失败'
                            });
                        }

                    },
                    complete: (XMLHttpRequest) => {

                        requestPretreatment(XMLHttpRequest);
                    }
                });
            }).catch(() => { });
        },
        //树的点击筛选事件
        handleNodeClick(data, node) {
            if (node.level == 1) {
                this.page.Condition = window.btoa(unescape(encodeURIComponent("%" + data.id + "%,%%,%"+this.page.value1+"%,%"+this.page.value2+"%")))
            } else if (node.level == 2) {
                this.page.Condition = window.btoa(unescape(encodeURIComponent("%%,%" + data.id + "%,%"+this.page.value1+"%,%"+this.page.value2+"%")))
            }
            this.postgetList(this.page);
        },
    },
};

const { createApp } = Vue;
const app = createApp(App);
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
const ElMessage = ElementPlus.ElMessage;
app.use(ElementPlus, { locale: zhCn });
app.mount("#app");
